Final Class in Java
A final class in Java is a class that is declared using the final keyword. Here are some key points about final classes:
$ A final class cannot be extended by a subclass.
$ The main purpose of using a class being declared as final is to prevent the class from being subclassed.
$ If a class is marked as final then no class can inherit any feature from the final class.
$ If you try to extend a final class, it gives you a compile-time error.
Final class basic syntax
final class FinalClass {
// class body
}
Abstract Class in Java
An abstract class in Java is a class that is declared using the abstract keyword. Here are some key points about abstract classes:
$ An abstract class cannot be instantiated on its own.
$ It serves as a blueprint for other classes and may contain one or more abstract methods.
$ An abstract method is a method that is declared but does not have an implementation.
$ Subclasses inheriting from an abstract class must implement these abstract methods.
Abstract class basic syntax
abstract class AbstractClass {
abstract void abstractMethod();
}